package src

import (
    "math/rand"
    "os"
    "os/exec"
    "runtime"
    "sort"
    "time"
)

func ClearScreen() {
    c := exec.Command("clear")
    switch runtime.GOOS {
    case "windows":
        c = exec.Command("cmd.exe", "/c", "cls")
    }

    c.Stdout = os.Stdout
    c.Run()
}

func RandomWakeUp() []int {
    total := width * height
    count := total / 4

    wakeUpMap := make(map[int]bool, count)
    for {
        if len(wakeUpMap) == count {
            break
        }

        rand.Seed(time.Now().UnixNano())
        wakeUpMap[rand.Intn(total)] = true
    }

    wakeUpSet := make([]int, 0, count)
    for k := range wakeUpMap {
        wakeUpSet = append(wakeUpSet, k)
    }
    sort.Ints(wakeUpSet)
    return wakeUpSet
}
